# ！/home/yang/PythonProjects python
# -*- coding: utf-8 -*-
# author:yang  time:19-7-25 上午8:52


def input_num():
    num_list = []
    while True:
        num = input("请输入数字(输入Q或q结束)：")
        if num == 'q' or num == 'Q':
            break
        else:
            num = int(num)
            num_list.append(num)
    return num_list


def sum_num():
    num_list = input_num()
    sum_ = 0
    for i in num_list:
        sum_ += i

    print("和为：", sum_)


def subtraction():
    num_list = input_num()
    sub_ = num_list[0]
    for i in range(1, len(num_list)):
        sub_ -= num_list[i]

    print("差为：", sub_)
    
       
def multiplication():
    num_list = input_num()
    mul_ = 1
    for i in num_list:
        mul_ *= i

    print("积为：", mul_)


def division():
    num_list = input_num()
    div_ = num_list[0]
    for i in range(1, len(num_list)):
        if num_list[i] == 0:
            print("除数不能为0")
            break
        div_ /= num_list[i]

    print("商为：", div_)


def main():
    while True:
        print("---------1. 加法---------")
        print("---------2. 减法---------")
        print("---------3. 乘法---------")
        print("---------4. 除法---------")
        print("---------0. 退出---------")

        num = int(input("请选择："))
        if num == 0:
            print("End")
            break
        if num == 1:
            sum_num()
        if num == 2:
            subtraction()
        if num == 3:
            multiplication()
        if num == 4:
            division()
            

if __name__ == '__main__':
    main()
